<template>
  <div>
    <mt-field label="学号" placeholder="请输入学号" v-model="number"></mt-field>
    <mt-field label="用户名" placeholder="请输入用户名" v-model="name"></mt-field>
    <mt-field label="学校" placeholder="请输入学校" v-model="school"></mt-field>
    <mt-field label="学院" placeholder="请输入学院" v-model="college"></mt-field>
    <mt-field label="系" placeholder="请输入系" v-model="department"></mt-field>
    <mt-field label="专业" placeholder="请输入专业" v-model="professional"></mt-field>
    <mt-field label="课程" placeholder="请输入课程" v-model="myClass"></mt-field>
    <mt-field label="密码" placeholder="请输入密码" type="password" v-model="password1"></mt-field>
    <mt-field label="重复密码" placeholder="请再输入密码" type="password" v-model="password2"></mt-field>
    <mt-button type="default" class="set-button1" @click="btnRegister">提交</mt-button>
    <mt-button type="default" class="set-button2" @click="btnChange">重置</mt-button>
  </div>
</template>

<script>
  import { MessageBox } from 'mint-ui';
  import { Button } from 'mint-ui';
  import { Field } from 'mint-ui';
  import axios from 'axios';

  export default {
    name: "regis-content",
    components:{
      MtField:Field,
      MtButton:Button
    },
    data:function () {
      return{
        number:'',
        name:'',
        password1:'',
        password2:'',
        password:'',
        school:'',
        college:'',
        department:'',
        professional:'',
        myClass:''
      }
    },
    methods:{
      btnChange:function () {
          this.number='';
          this.name='';
          this.password1='';
          this.password2='';
          this.password='';
          this.school='';
          this.college='';
          this.department='';
          this.professional='';
          this.myClass='';
      },
      btnRegister:function () {
        if(this.password1 === this.password2){
          console.log("验证通过");
          MessageBox('提示', '操作成功');
          this.$router.push('/');
          // axios.post('http://23.83.244.88:8080/addStudent',
          //   {
          //   "number":this.number,
          //   "name":this.name,
          //   "school":this.school,
          //   "college":this.college,
          //   "department":this.department,
          //   "professional":this.professional,
          //   "myclass":this.myclass,
          //   "password":this.password
          // }
          // ).then(this.btnRegisterSucc)
          //   .catch(err => {
          //     console.log(err);
          //   });
        }},
      // btnRegisterSucc:function (res) {
      //   console.log(res);
      //   MessageBox('提示', '操作成功');
      //   this.$router.push('/');
      // }
    }
  }
</script>

<style scoped>
  .set-button1{
    margin-top: 1rem;
    margin-left: 0rem;
    margin-right: 6.5rem;

  }
  .set-button1{
    margin-top: 1rem;
    margin-right: 3rem;
  }
</style>
